﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Markup;
using System.Windows.Data;
using DevExpress.Xpf.Grid;

namespace ThanNhanTao.CommonControl
{
    public class ConvertCommon
    {
    }

    /// <summary>
    /// Class Converter "Dùng cho ngoại nội trú" From byte To String
    /// </summary>
    public class GioiTinhConverterToString : MarkupExtension, IValueConverter
    {
        #region IValueConverter Members

        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (value == null) return string.Empty;

            bool gioiTinh = (bool)(value);
            return (gioiTinh == true ? "Nam" : "Nữ");
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }

        #endregion

        public override object ProvideValue(IServiceProvider serviceProvider)
        {
            return this;
        }
    }

    public class RowHandleToStringConverter : MarkupExtension, IValueConverter
    {
        #region IValueConverter Members
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            int rowHandle = System.Convert.ToInt32(value);

            if (rowHandle == GridControl.NewItemRowHandle || rowHandle == GridControl.AutoFilterRowHandle)
                return string.Empty;

            rowHandle++;
            return rowHandle.ToString();
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
        #endregion

        public override object ProvideValue(IServiceProvider serviceProvider)
        {
            return this;
        }
    }
}
